//
//
//
#include "portocolMyGiftList.h"
#include <utf.h>

_LIT8(KInterfaceNo, "interfaceno");

_LIT8(KReqMyGiftListURL, "http://58.246.187.214/client.php?ac=mygiftlist");
_LIT8(KReqMyGiftListData, "uid=%s&rand=%s&source=%d&index=%d&robot=%s");
_LIT(KReqInfoNone, "\"\"");

CRocketRequestMyGiftList::CRocketRequestMyGiftList(MNetworkEventObervser* aObserver) : CRocketRequest(aObserver)
	{
		iUrl.Copy(KReqMyGiftListURL());
		iNumber = CMSGMYGIFTLIST;
	}

CRocketRequestMyGiftList::~CRocketRequestMyGiftList()
	{
		
	}
_LIT8(KRobotInfo, "%d#%d#%d%");
void CRocketRequestMyGiftList::SetInfo(const TDesC8& aUid, const TDesC8& aRand, TInt aSource, TInt aPageIndex,
										TInt aRobotGiftID, TInt aRobotMsgIndex, TInt aRobotNO)
{
	iUid.Zero();
	iRand.Zero();
	iRobotInfo.Zero();
	
	iUid.Copy(aUid);
	iRand.Copy(aRand);
	iSource = aSource;
	iIndex = aPageIndex;
	
	iRobotInfo.Format(KRobotInfo, aRobotGiftID, aRobotMsgIndex, aRobotNO);
}

TBool CRocketRequestMyGiftList::Encode()
{	
	TBuf8<2048> buf;
	buf.Format(KReqMyGiftListData(),
				iUid.PtrZ(),
				iRand.PtrZ(),
				iSource,
				iIndex,
				iRobotInfo.PtrZ());
	
	this->iData = buf.Alloc();
	return ETrue;
}

CRocketResponseMyGiftList::CRocketResponseMyGiftList()
	{
	
	}

CRocketResponseMyGiftList::~CRocketResponseMyGiftList()
	{
	
	}

void CRocketResponseMyGiftList::OnEndElementL(const Xml::RTagInfo &aElement, 
										TInt aErrorCode)
{
	
}

// XML tags
_LIT8(KRegisterTag, "mygiftlist");
_LIT8(KRetTag, "ret");

void CRocketResponseMyGiftList::OnStartElementL(const Xml::RTagInfo& aElement,
						const Xml::RAttributeArray& aAttributes,
						TInt aErrorCode)
{
	if(aElement.LocalName().DesC() == KInterfaceNo)
	{
		
	}
	else if(aElement.LocalName().DesC() == KRegisterTag)
	{
		for(TInt nIndex = 0; nIndex < aAttributes.Count(); nIndex ++)
		{
			//Xml::RAttribute attr = aAttributes.At(nIndex);
			if(0 == aAttributes[nIndex].Attribute().LocalName().DesC().Compare(KRetTag))
			{
				TLex8 aLex(aAttributes[nIndex].Value().DesC());
				aLex.Val(iReturnNumber);
			}
		}
	}
}
